package com.borya.action.mobile;


import com.alibaba.fastjson.JSONObject;
import com.borya.action.BaseAction;
import com.borya.framework.annotation.Action;
import com.borya.framework.annotation.Autowired;
import com.borya.framework.annotation.JsonResult;
import com.borya.framework.annotation.UrlMapping;
import com.borya.framework.core.ServerRequest;
import com.borya.framework.core.ServerResponse;
import com.borya.model.db.User;
import com.borya.service.mobile.SdkAppJobNumberService;
import com.borya.service.mobile.SdkAppService;
import org.apache.log4j.Logger;

/**
 * rxg 2020-3-31
 * 单点结算app SDK工号管理接口
 * @author borya
 */
@UrlMapping("/c/sdkAppJobNumber/")
@Action
public class SdkAppJobNumberAction extends BaseAction {

    private Logger log = Logger.getLogger(getClass());

    @Autowired("sdkAppJobNumberServiceImpl")
    private SdkAppJobNumberService sdkAppJobNumberService;

    /**
     * 添加子工号，工号管理展示界面
     * @param request
     * @param response
     * @return
     */
    @UrlMapping("getJobNumberUserList")
    @JsonResult
    public String getJobNumberUserList(ServerRequest request, ServerResponse response) {
        JSONObject json = getJson(request);
        String result = sdkAppJobNumberService.getJobNumberUserList(json,request);
        log.info("INFO[" + json + "],OUT[" + result + "]");
        return result;
    }

    /**
     *添加子工号，查看日志
     * @param request
     * @param response
     * @return
     */
    @UrlMapping("getJobNumberManageLogList")
    @JsonResult
    public String getJobNumberManageLogList(ServerRequest request, ServerResponse response) {
        User user = getUser(request);
        String result = sdkAppJobNumberService.getManageLogList(user);
        log.info("INFO[getJobNumberManageLogList],OUT[" + result + "]");
        return result;
    }

    /**
     *添加子工号，提交
     * @param request
     * @param response
     * @return
     */
    @UrlMapping("createJobNumUser")
    @JsonResult
    public String createUser(ServerRequest request, ServerResponse response) {
        JSONObject json = getJson(request);
        String result = sdkAppJobNumberService.createUser(request);
        log.info("INFO[" + json + "],OUT[" + result + "]");
        return result;
    }

    @UrlMapping("getCreateJobNumberCode")
    @JsonResult
    public String getCreateCode(ServerRequest request, ServerResponse response) {
        JSONObject json = getJson(request);
        String result = sdkAppJobNumberService.getCreateCode(request);
        log.info("INFO[" + json + "],OUT[" + result + "]");
        return result;
    }

    /**
     *添加子工号，用户详情
     * @param request
     * @param response
     * @return
     */
    @UrlMapping("getJobNumberUserDetailList")
    @JsonResult
    public String getUserDetailList(ServerRequest request, ServerResponse response) {
        JSONObject json = getJson(request);
        String result = sdkAppJobNumberService.getJobNumberUserDetailList(request);
        log.info("INFO[" + json + "],OUT[" + result + "]");
        return result;
    }

    /**
     * 获取子工号协议数据(带签名的合成协议)
     */
    @UrlMapping("getSonJobNumProtocol")
    @JsonResult
    public String getSonJobNumProtocol(ServerRequest request, ServerResponse response) {
        JSONObject json = getJson(request);
        String result = sdkAppJobNumberService.getSonJobNumProtocol(request);
        log.info("INFO[" + json + "],OUT[" + result + "]");
        return result;
    }

    @UrlMapping("removeJobNumUser")
    @JsonResult
    public String removeJobNumUser(ServerRequest request, ServerResponse response) {
        JSONObject json = getJson(request);
        String result = sdkAppJobNumberService.removeUser(request);
        log.info("INFO[" + json + "],OUT[" + result + "]");
        return result;
    }

}
